package ge.telasi.tasks.ejb;

import java.util.Properties;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 * @author dimitri
 */
public class TaskFacadeClient {

    public static TaskFacadeRemote getRemoteFacade() throws NamingException {
        return getRemoteFacade("localhost", "3700");
    }

    public static TaskFacadeRemote getRemoteFacade(String host, String port) throws NamingException {
        Properties props = new Properties();
        props.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
        props.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
        props.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
        props.setProperty("org.omg.CORBA.ORBInitialHost", host);
        props.setProperty("org.omg.CORBA.ORBInitialPort", port);
        props.setProperty("java.naming.provider.url", "iiop://" + host + ":" + port);
        InitialContext ic = new InitialContext(props);
        TaskFacadeRemote facade = (TaskFacadeRemote) ic.lookup("ge.telasi.tasks.ejb.TaskFacadeRemote");
        return facade;
    }
    
}
